<?php require_once ('../common/check.php');  //权限校验 ?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>后台管理系统</title>
		<link href="images/index.css" type="text/css" rel="stylesheet"/>
		<script src="images/jquery.js"></script>
	</head>
	<body>
        <?php require "top.php" ?>
		<section>
            <?php require "left.php" ?>
			<div class="mainbox">
				<div class="note">
					<h4>文章分类列表</h4>
					<table class="news_list">
						<thead>
							<tr>
                                <th>ID</th>
								<th>文章作者</th>
								<th>文章标题</th>
								<th>文章内容</th>
								<th>文章图片</th>
                                <th>添加时间</th>
                                <th>文章分类</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
                        <?php
                         //>>1.连接数据库
                            require('../common/conn.php');
                         //>>2.
                            $sql = "select * from article";
                            $result= mysqli_query($link,$sql);
                            if($result===false){ //表示执行的sql有错误sql
                                echo "错误代码: ".mysqli_errno($link)."<br/>";
                                echo "错误信息: ".mysqli_error($link)."<br/>";
                                echo "SQL语句: ".$sql;
                                exit;
                            }
                            $rows = mysqli_fetch_all($result,MYSQLI_ASSOC);
                            foreach($rows as $row):
                        ?>
							<tr>
								<td><?=$row['id']?></td>
								<td><?=$row['author']?></td>
								<td><?=$row['title']?></td>
								<td><?=$row['content']?></td>
                                <td><img src="<?=$row['img']?>" width="300" height="100"></td>
                                <td><?=$row['add_time']?></td>
                                <td><?=$row['category']?></td>
								<td>
									<a href="article.php?action=edit&id=<?=$row['id']?>">修改</a>
									<a href="article.php?action=del&id=<?=$row['id']?>">删除</a>
								</td>
							</tr>
                            <?php endforeach;?>
						</tbody>
					</table>
				</div>
			</div>
		</section>
		<script>
			$(function(){
				$('dt').click(function(){
					var obj=$(this).next();
					if($(this).next().css('display')=='block'){
						obj.hide('fast');
						$(this).removeClass('on');
					}else{
						obj.show('fast');
						$(this).addClass('on');
					}
				});
			});
		</script>
	</body>
</html>